package com.cos.hospital.ui.record.adapter;

import android.support.annotation.Nullable;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.cos.hospital.R;
import com.cos.hospital.ui.record.bean.BeanRecord;

import java.util.List;

/**
 * @Description: 添加病历元素
 * @Author: Kosmos
 * @Date: 2018年09月22日 20:52
 * @Email: KosmoSakura@foxmail.com
 */
public class AdapterElement extends BaseQuickAdapter<BeanRecord, BaseViewHolder> {
    private int selectPosition;

    public void setSelectPosition(int selectPosition) {
        this.selectPosition = selectPosition;
    }

    public int getSelectPosition() {
        return selectPosition;
    }

    public AdapterElement(@Nullable List<BeanRecord> data) {
        super(R.layout.item_element, data);
        selectPosition = -1;
    }

    @Override
    protected void convert(BaseViewHolder helper, BeanRecord item) {
        View layRoot = helper.getView(R.id.ele_root);
        if (helper.getLayoutPosition() == selectPosition) {
            layRoot.setBackgroundResource(R.drawable.rect_rim_orange);
        } else {
            layRoot.setBackgroundResource(R.color.white);
        }
        helper.setText(R.id.ele_name, item.getFldElementName());
    }
}
